<?PHP


//*			content functions		*/

function get_content_by_title($title)
	{
										$content=new content_data();
										$content->content_title=$title;
										$data=$content->get_content_by_name();
										$data=current($data);
										return $data;
	}

function convert_string_to_query($string)
{
	  $string = str_replace(" ", "-", $string);
	  $string = strtolower($string);
	
	return $string;
}

function csq($string)
{
	  $string = str_replace(" ", "-", $string);
	  $string = strtolower($string);
	
	return $string;
}
	
function get_extension($file)
{
		return substr(strrchr($file, "."), 1);
}
function options_checker($var,$val)
{	
	
//	//rp($var);
	

	
		
		foreach($var as $var_key => $value)
		{
			foreach($val as $val_key => $value)
			{
				if ($val_key==$var_key){
					$x[$val_key]=$value;
					
				//	echo ' meron '.$val_key.'-'.$x[$val_key].' <br />';
			
				}
			}
			
			
				if (!empty($x[$var_key])){
					$output[$var_key]=$x[$var_key];
				//	echo 'pitik: '.$x[$var_key];
				}
				else
				{
			 		$output[$var_key]=$var[$var_key];
				}
		}


	
//	//rp($output);
	
	return $output;
	
}

function p_hidden($name,$o,$val)
{
		$d['label']='';
		$d['size']=40;
		$d['max']=99;

		$d['tooltip']='';
		$d['password']=FALSE;
		$d['error']='';
		
		$value=$val[$name];
		echo	"<input id='".$name."' type='hidden' name='".$name."' class='".$class."' size=".$v['size']." maxlength='".$v['max']."' value='".$value."' >";
}
function p_checkbox($name,$o,$val)
{
		$d['label']='';
		$d['size']=40;
		$d['max']=250;

		$d['tooltip']='';
		$d['password']=FALSE;
		$d['error']='';
		
		$value=$val[$name];
		
		if($value==1)
		{
			$checked='CHECKED';
		}
		
		$v=options_checker($d,$o);	
		$class="textinput ".$v['error'];
	
		if(empty($v['label']))
		{
			$label=str_replace("_", " ", $name);;
			
		}		
		else
		{
			$label=$v['label'];
		}
		
		echo "<div class='fi input_holder'>
					  <label for=".$name.">".$label."</label>";
			if(!empty($v['tooltip']))
			{
				echo "	<p class='datatip'>".$v['tooltip']."</p>";
			}	
		
				?>
			
					<input type="checkbox" name="<?PHP echo $name;?>" value="1" id="<?PHP echo $name;?>" <?PHP echo $checked;?> >
				<?PHP	
		echo			"</div>";
}
function p_input($name,$o,$val)
{
		
				$d['label']='';
				$d['size']=40;
				$d['max']=250;
		
				$d['tooltip']='';
				$d['password']=FALSE;
				$d['error']='';
				
				$value=$val[$name];
		
				
				$v=options_checker($d,$o);	
				$class="textinput ".$v['error'];
			
				if(empty($v['label']))
				{
					$label=str_replace("_", " ", $name);;
					
				}		
				else
				{
					$label=$v['label'];
				}
				
				echo "<div class='fi input_holder'>
							  <label for=".$name.">".$label."</label>";
					if(!empty($v['tooltip']))
					{
						echo "	<p class='datatip'>".$v['tooltip']."</p>";
					}	
				
				echo		"<input id='".$name."' ";
				if($v['password']){echo " type='password' ";}else{echo " type='text' ";}
				echo 		" name='".$name."' class='".$class."' size=".$v['size']." maxlength='".$v['max']."' value='".$value."' >";
							
				echo			"</div>";
							
}

function p_file($name, $o)
{	
	
	$d['label']='';
	$d['size']=40;
	$d['max']=99;

	$d['tooltip']='';
	$d['password']=FALSE;
	$d['error']='';
	
	$value=$val[$name];

	
	$v=options_checker($d,$o);	
	
	if(empty($v['label']))
	{
		$label=str_replace("_", " ", $name);;
		
	}		
	else
	{
		$label=$v['label'];
	}
	
	
	$class="textinput ".$v['error'];
	echo "<div class='fi file_holder' ><label for='".$name."'>".$label; 
	

	
	echo "</label>"; 
	
	if(!empty($v['tooltip']))
	{
		echo "	<p class='datatip'>".$v['tooltip']."</p>";
	}
	
	echo"<input name='".$name."' class='filebox ".$class."' type='file'></div> ";
							

}

function p_select($name,$data,$val,$key,$var,$o)
{

//function p_select($name,$data,$selectedvalue, $tooltip, $title)

$d['label']='';
$d['none']=FALSE;
$d['size']=50;
$d['max']=5;

$d['tooltip']='';
$d['error']='';
$d['required']=FALSE;
$value=$val[$name];
//$o		


$v=options_checker($d,$o);	
$class="textarea ".$v['error'];
if(empty($v['label']))
{
	$label=str_replace("_", " ", $name);;
	
}		
else
{
	$label=$v['label'];
}
echo "	<div class='fi input_holder'>";
echo "<label for=".$name.">".$label."</label>";
if(!empty($v['tooltip']))
{
	echo "	<p class='datatip'>".$v['tooltip']."</p>";
}
echo "<select name=".$name." id=".$name." class='formselect ".$class."' >";
if($v['none'])
{
	echo "<option value='0' disabled='disabled' SELECTED> - Please Select  -</option>";
}
foreach ($data as $v1) {

				echo "<option ";

				if($v1[$key]==$value)
				{ echo " selected='selected' ";}
				echo "value=".$v1[$key];
			
				echo ">".$v1[$var]."</option>";

		

   
}
echo "</select>	</div>";
}


function p_date($name,$o,$val)
{
	$d['label']='';
	$d['none']=FALSE;
	$d['size']=50;
	$d['max']=5;

	$d['tooltip']='';
	$d['error']='';

	$value=$val[$name];

	//$o		


	$v=options_checker($d,$o);	
	$class="textarea ".$v['error'];
	if(empty($v['label']))
	{
		$label=str_replace("_", " ", $name);;

	}		
	else
	{
		$label=$v['label'];
	}
			echo "<div class='fi input_holder'>
							  <label for=".$name.">".$label."</label>";
					if(!empty($v['tooltip']))
					{
						echo "	<p class='datatip'>".$v['tooltip']."</p>";
					}	
				echo		"<input id=".$name." type=text name=".$name." class=textinput size=".$size." maxlength=".$max." value='".$value."'   >
							
							</div>";
							
							
							?><script type="text/javascript">
							$(function() {
								$("#<?PHP echo $name;?>").datepicker();
								$('#<?PHP echo $name;?>').datepicker('option', {dateFormat: "yy-mm-dd"}); });
							</script>
							
							<?PHP

}

function delete_item()
{

	echo " <div class='fi input_holder'><input type='submit' value='delete' name='delete' class=buttonSubmit /></div>";
}


function p_table($headers,$array,$links, $attributes, $show,$ajax_array,$paginate=FALSE)
{	
	if($paginate)
	{
		$page = new paginator;
		$page->data=$array;
		$array=$page->paginate();
	}

	
	$name=randomchar();
	echo "<table ".$attributes." class='sortme' cellspacing='0' id='".$name."'>";
	if(!empty($headers)){
		echo "<thead>";
		foreach ($headers as $x) {
?>
		
			
				<th><?PHP echo $x;?></th>
				
		
<?PHP	 
		}
		echo "</thead>";
	}
	foreach ($array as $x)
	{?>
	
		<tr>
			<?PHP
			//$r=0;
			foreach($show as $z)
			{
				echo "<td>".$x[$z]."</td>";
			}
			
		
			?>
		
			<td>
				<?PHP
				
					foreach($links as $links_key => $value)
					{
							if(isset($x[0])){echo "<a href='".$links[$links_key].$x[0]."'>".$links_key."</a>";};
					//	echo $links[$links_key];
					}
				
				?>
				<?PHP
				
					foreach($ajax_array as $ajax_key => $value)
					{ 
						echo '<a href="#" id="'.$x[0].'" class="'.$ajax_key.'">'.$ajax_key.'</a>';
					}
					
				?>
				
			</td>
		</tr>
	
	<?PHP }
	echo "</table>";
	if($paginate)
	{
		$page->print_pager();
	}
	?>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
		    $('#<?PHP echo $name;?> tbody tr').quicksearch({ position: 'before', attached: '#<?PHP echo $name;?>',stripeRowClass: ['', 'even'],labelText: 'Find'}); 
		});
		
		<?PHP
		
			foreach($ajax_array as $ajax_key => $value)
			{ 
		?>
		
			$(function() {
			$(".<?PHP echo $ajax_key;?>").click(function() {

			var commentContainer = $(this).parent().parent();

			var id = $(this).attr("id");
			var string = 'id='+ id ;

				var answer = confirm("<?PHP echo $ajax_key;?> this item?")
			            if (answer){
			                $.ajax({
							   type: "POST",
							   url: "<?PHP echo $ajax_array[$ajax_key];?>",
							   data: string,
							   cache: false,
								<?PHP if($ajax_key=='Delete'){?>
							   			success: function(){
										commentContainer.fadeOut('slow', function() {$(this).remove();});
										}
								<?PHP };?>
							  

							 });
			            }
			            else{
			                return false;
			            };
						return false;
				});
			});
		
		
				
		<?PHP

			}
			
		?>

	
		
		
		
	</script>
	
	<?PHP
}

function p_table_delete($headers,$array,$links, $attributes, $show,$ajax_array)
{	
	
	$name=randomchar();
	echo "<table ".$attributes." class='sortme' cellspacing='0' id='".$name."'>";
	if(!empty($headers)){
		echo "<thead>";
		foreach ($headers as $x) {
?>
		
			
				<th><?PHP echo $x;?></th>
				
		
<?PHP	 
		}
		echo "</thead>";
	}
	foreach ($array as $x)
	{?>
	
		<tr>
			<?PHP
			//$r=0;
			foreach($show as $z)
			{
				echo "<td>".$x[$z]."</td>";
			}
			
		
			?>
		
			<td>
				<?PHP
				
					foreach($links as $links_key => $value)
					{
							if(isset($x[0])){echo "<a href='".$links[$links_key].$x[0]."'>".$links_key."</a>";};
					//	echo $links[$links_key];
					}
				
				?>
				<?PHP
				
					foreach($ajax_array as $ajax_key => $value)
					{ 
						echo '<a href="#" id="'.$x[0].'" class="'.$ajax_key.'">'.$ajax_key.'</a>';
					}
					
				?>
				
			</td>
		</tr>
	
	<?PHP }
	echo "</table>";
	?>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
		    $('#<?PHP echo $name;?> tbody tr').quicksearch({ position: 'before', attached: '#<?PHP echo $name;?>',stripeRowClass: ['', 'even'],labelText: 'Find'}); 
		});
		
		<?PHP
		
			foreach($ajax_array as $ajax_key => $value)
			{ 
		?>
		
			$(function() {
			$(".<?PHP echo $ajax_key;?>").click(function() {

			var commentContainer = $(this).parent().parent();

			var id = $(this).attr("id");
			var string = 'id='+ id ;
			

				var answer = confirm("<?PHP echo $ajax_key;?> this item?")
			            if (answer){
			                $.ajax({
							   type: "POST",
							   url: "<?PHP echo $ajax_array[$ajax_key];?>",
							   data: string,
							   cache: false,
								<?PHP if($ajax_key=='Delete'){?>
							   			success: function(){
										commentContainer.fadeOut('slow', function() {$(this).remove();});
										}
								<?PHP };?>
							  

							 });
			            }
			            else{
			                return false;
			            };
						return false;
				});
			});
		
		
				
		<?PHP

			}
			
		?>

	
		
		
		
	</script>
	
	<?PHP
}

function p_submit($name,$id)
{			echo " <div class='fi formsubmit'><input type=submit value=".$name." class='buttonSubmit' id='".$id."' /></div>";
			
}


function p_head($text)
{
	?>
		<h2><?PHP echo $text;?></h2>
	<?PHP
}
function p_text($name,$o,$val)
{			
//function printtext($name,$id,$label,$size,$max,$value)	
	
	$d['label']='';
	$d['size']=50;
	$d['max']=5;

	$d['tooltip']='';
	$d['password']=FALSE;
	$d['error']='';
	
	$value=$val[$name];
	//$o		
	
	
	$v=options_checker($d,$o);	
	$class="textarea ".$v['error'];
	if(empty($v['label']))
	{
		$label=str_replace("_", " ", $name);
		
	}		
	else
	{
		$label=$v['label'];
	}
			echo "<div class='fi textbox_holder'>	  <label for=".$name.">".$label."</label>";
			echo "<textarea id='".$name."' class='".$class."' name=".$name." cols='".$size."' rows='".$max."'>".$value."</textarea></div>";
}

function begin_form($cmd,$id,$q,$cleanurl)
{
	
	if(empty($q))
	{
		$q=$_GET['q'];
	}
	if($cleanurl)
	{
	?>

				<form action="<?PHP echo $conf->path.$q;?>" method="POST" accept-charset="utf-8" enctype="multipart/form-data" id='data_form' name='data_form'>
		<?PHP		
	}
	else
	{
	
	?>

		<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>?q=<?PHP echo $q;?>&cmd=<?PHP echo $cmd;?>&<?PHP echo $id?>=<?PHP echo $_GET[$id];?>" method="POST" accept-charset="utf-8" enctype="multipart/form-data" id='data_form'>
<?PHP
	}
}

function end_form($cmd)
{ 
	?>
	
	<input type="hidden" name="cmd" value="<?PHP echo $cmd;?>">
	</form>
	
				<script type="text/javascript" charset="utf-8">
				$().ready(function() {

						$("#data_form").validate();
						
						
				});
			</script>
	
<?PHP	
}
function check_page_redirect($var,$page)
{
	if(empty($var))
	{
		page_redirect($page);
	}
}
function page_redirect($page)
{
	?>
	<script type="text/javascript">
	<!--
	window.location = "<?PHP echo $page;?>"
	//-->
	</script>
	<?PHP
}


//CONTENT FUNCTIONS
function get_category_by_name($name)
{
$category_query= new category();
return $category_query->get_category_id($name);	
}
function p_r($array)
{
	//rp($array);
}
function m_r($my_array) {
    if (is_array($my_array)) {
        echo "<table border=1 cellspacing=0 cellpadding=3 width=100%>";
        echo '<tr><td colspan=2 style="background-color:#333333;"><strong><font color=white>ARRAY</font></strong></td></tr>';
        foreach ($my_array as $k => $v) {
                echo '<tr><td valign="top" style="width:40px;background-color:#F0F0F0;">';
                echo '<strong>' . $k . "</strong></td><td>";
                myprint_r($v);
                echo "</td></tr>";
        }
        echo "</table>";
        return;
    }
    echo $my_array;
}

function get_clean_queries()
{
	global $conf;
	$queries='?';
	
	if(!empty($conf->q))
	{
		$queries.='&q='.$conf->q;	
	}
	
	if(!empty($conf->hash))
	{
		$queries.='&hash='.$conf->hash;	
	}
	if(!empty($conf->id))
	{
		$queries.='&id='.$conf->id;	
	}
	if(!empty($conf->find))
	{
		$queries.='&find='.$conf->find;	
	}
	return $queries;
	
}

function get_clean_url_queries()
{
	global $conf;
	$queries='';
	
	if(!empty($conf->q))
	{
		$queries.=''.$conf->q;	
	}

	if(!empty($conf->hash))
	{
		$queries.='&hash='.$conf->hash;	
	}
	if(!empty($conf->id))
	{
		$queries.='&id='.$conf->id;	
	}
	if(!empty($conf->find))
	{
		$queries.='&find='.$conf->find;	
	}
	return $queries;
	
}
?><?PHP

function check_email_address($email) {
    // First, we check that there's one @ symbol, and that the lengths are right
    if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
        // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
        return false;
    }
    // Split it into sections to make life easier
    $email_array = explode("@", $email);
    $local_array = explode(".", $email_array[0]);
    for ($i = 0; $i < sizeof($local_array); $i++) {
         if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
            return false;
        }
    }    
    if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
        $domain_array = explode(".", $email_array[1]);
        if (sizeof($domain_array) < 2) {
                return false; // Not enough parts to domain
        }
        for ($i = 0; $i < sizeof($domain_array); $i++) {
            if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
                return false;
            }
        }
    }
    return true;
}
			function printdisplayheader($title,$instructions)
{
	echo '
			<div class="dataholder">
			<div class="datatop">
			'.$title.'
			</div>
			<div class="datalabel">'.$instructions.'</div>
			<div class="datadata">
	';
}

function printdisplayfooter($link1name,$link1,$link2name,$link2,$link3name,$link3)
{
	echo '</div><div class="datafootbg">';
				if(isset($link1) && isset($link1name))
				{
					echo '<a href='.$link1.'>'.$link1name.'</a> ';				
				}
				
				if(isset($link2) && isset($link2name))
				{
					echo '<a href='.$link2.'>'.$link2name.'</a> ';				
				}
				
				if(isset($link3) && isset($link3name))
				{
					echo '<a href='.$link3.'>'.$link3name.'</a> ';				
				}
	echo '</div></div>';
}								


function wp_mktime($_timestamp = ''){
    if($_timestamp){
        $_split_datehour = explode(' ',$_timestamp);
        $_split_data = explode("-", $_split_datehour[0]);
        $_split_hour = explode(":", $_split_datehour[1]);

        return mktime ($_split_hour[0], $_split_hour[1], $_split_hour[2], $_split_data[1], $_split_data[2], $_split_data[0]);
    }
}

function display_host_tinymce()
{
	$host=$_SERVER['PHP_SELF'];
	$waka=explode("/",$host);
	$y="";
	$z=count($waka)-2;
	$w=0;
	foreach($waka as $x)
	{
		
		if($w<=$z){$y.=$x."/";};
		$w++;
	}
	echo $y."..";
}
function printformheader($title,$instructions)
{
	echo '
			<div class="formholder">
			<div class="datatop">
			'.$title.'
			</div>
			<div class="datalabel">'.$instructions.'</div>
			<div class="datadata">
	';
}

function printformfooter($link1name,$link1,$link2name,$link2,$link3name,$link3)
{
	echo '</div><div class="datafootbg">';
				if(isset($link1) && isset($link1name))
				{
					echo '<a href='.$link1.'>'.$link1name.'</a> ';				
				}
				
				if(isset($link2) && isset($link2name))
				{
					echo '<a href='.$link2.'>'.$link2name.'</a> ';				
				}
				
				if(isset($link3) && isset($link3name))
				{
					echo '<a href='.$link3.'>'.$link3name.'</a> ';				
				}
	echo '</div></div>';
}

function printmessage($message)
{
	echo "<div class='sm'>".$message."</div>";
}

function pm($message)
{

		echo "<div class='pm'>".$message."</div>";
	
	
}

function em($message)
{

		echo "<div class='em'>Error: ".$message."</div>";
	
	
}

function mp($message)
{
	global $conf;
	if($conf->debug)
	{	
		
			error_log($message,0);
		//	echo "<div class='sm'>".$message."</div>";
	
	}
}
function rp($array)
{
//	global $conf;
	if($conf->debug)
	{
		
		
		//	error_log($array,0);
		echo "<div class='sm rp'>";
		
		?>

		<input type="text" name="some_name" value="<?PHP  print_r($array);?>" id="some_name" multiline>
		<?PHP
		echo "</div>";
	
	}
}
function image_print($message)
{
	global $conf;
	
	if(!empty($message))
	{
		$image=$conf->photo_dir.$message;
		echo "<div class=imagepreview><img src='".$image."'></img></div>";
	}
}


function thick_box($image,$thumb)
{
	global $conf;
	$id=$thumb;
	if(!empty($image))
	{
		$image=ap($image);
		$thumb=ap($thumb);
	//	$image=.$image;
	//	$thumb=$conf->thumb_dir.$thumb;
		$id=randomchar();
		echo "<div class='forminfoholder'><a href='".$image."' class='".$id."'><img src='".$thumb."' ></img></a> <p class=datatip>Click to Zoom</p></div>";
		
	}
		?>
		
		<script type="text/javascript" charset="utf-8">
			
			$(document).ready(function() {
				$("a.<?PHP echo $id;?>").fancybox();
				
			});
		</script>
		
		<?PHP	
	
}

function thick_box_gallery($images,$i,$t,$n)
{
	global $conf;
	$id=randomchar();

		
		foreach($images as $x)
		{
			$image=ap($x[$i]);
			$thumb=ap($x[$t]);
			
			if(!empty($n))
			{
				$title=$x[$n];
			}
			
			?>
				
			<li>
				<a href='<?PHP echo $image;?>' class='<?php echo $id;?>' rel='gallery' title='<?php echo $title;?>'>
					<img src='<?PHP echo $thumb;?>'></img>
				</a>
			</li>
			<?PHP
		}
		
		?>
		
				<script type="text/javascript" charset="utf-8"> 
							$(document).ready(function() {

									$("a.<?PHP echo $id;?>").fancybox({
										'transitionIn'	:	'elastic',
										'transitionOut'	:	'elastic',
										'speedIn'		:	600, 
										'speedOut'		:	200, 
										'padding'		:   0,
										'overlayShow'	:	false
									});
							});


					</script>
		
		<?PHP
}

function p_image($image,$alt)
{
	global $conf;
	$id=$thumb;
	if(!empty($image))
	{
		$image=f_path($image,$conf->photo_dir);
	
	//	$image=.$image;
	//	$thumb=$conf->thumb_dir.$thumb;
		$id=randomchar();
		echo "<img src='".$image."' alt='".$alt."'>";
		
	}
}

function f_path($file,$dir)
{
	global $conf;
	$dir= strstr($dir, 'media');
	$x=$conf->httpcode.$_SERVER['HTTP_HOST'].$conf->path.$dir.$file;
	return $x;
}
function ap($file)
{
	global $conf;
	$dir=strstr($conf->photo_dir, 'media');
	if($conf->test_content)
	{
		if($conf->a['s3-image-enabled']=='true')
		{
			$x=$conf->httpcode.$conf->a['s3-image-cf'].'/'.$file;
		}
		else
		{
			$x=$conf->httpcode.$conf->pro['url'].$conf->path.$dir.$file;
		}
		
	}
	else
	{
		if($conf->a['s3-image-enabled']=='true')
		{
			$x=$conf->httpcode.$conf->a['s3-image-cf'].'/'.$file;
		}
		else
		{
			$x=$conf->httpcode.$_SERVER['HTTP_HOST'].$conf->path.$dir.$file;
		}
		
	}
	
	return $x;
}
function video_box($file)
{
	global $conf;
	$x=f_path($file,$conf->video_dir);
//	echo "<br />".$x;

//	$file="http://localhost:8888/p/s/admin/../media/videos/".$file;

	

	?>

	
	<script type="text/javascript" src="j/v/swfobject.js"></script>
	
		<div class='forminfoholder'>
		<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="480">
			<param name="movie" value="j/v/player-viral.swf" />
			<param name="allowfullscreen" value="true" />
			<param name="allowscriptaccess" value="always" />
			<param name="flashvars" value="file=<?PHP echo $x; ?>" />
			<object type="application/x-shockwave-flash" data="j/v/player-viral.swf" width="640" height="480">
				<param name="movie" value="j/v/player-viral.swf" />
				<param name="allowfullscreen" value="true" />
				<param name="allowscriptaccess" value="always" />
				<param name="flashvars" value="file=<?PHP echo $x; ?>" />
				<p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>
			</object>
		</object>
		
		</div>
	<?PHP
	
}

function video_box_main($file)
{
	global $conf;
	$x=f_path($file,$conf->video_dir);
//	echo "<br />".$x;

//	$file="http://localhost:8888/p/s/admin/../media/videos/".$file;

	

	?>

	
	<script type="text/javascript" src="admin/j/v/swfobject.js"></script>
	
		<div class='forminfoholder'>
		<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="618" height="418">
			<param name="movie" value="admin/j/v/player-viral.swf" />
			<param name="allowfullscreen" value="true" />
			<param name="allowscriptaccess" value="always" />
s
			<param name="flashvars" value="file=<?PHP echo $x; ?>" />
			<object type="application/x-shockwave-flash" data="admin/j/v/player-viral.swf" width="618" height="418">
				<param name="movie" value="admin/j/v/player-viral.swf" />
				<param name="allowfullscreen" value="true" />
				<param name="allowscriptaccess" value="always" />
				<param name="flashvars" value="file=<?PHP echo $x; ?>" />
				<p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>
			</object>
		</object>
		
		</div>
	<?PHP
	
	
}


function video_box_new($file)
{
	global $conf;
	$x=f_path($file,$conf->video_dir);

	

	?>

	
	<script type="text/javascript" src="admin/j/v/swfobject.js"></script>
	
		<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="618" height="418">
			<param name="movie" value="admin/j/v2/player.swf" />
			<param name="allowfullscreen" value="true" />
			<param name="allowscriptaccess" value="always" />
			<param name="wmode" value="transparent" />
			<param name="flashvars" value="swfMovie=<?PHP echo $x; ?>" />
			<object type="application/x-shockwave-flash" data="admin/j/v2/player-viral.swf" width="618" height="418">
				<param name="movie" value="admin/j/v2/player.swf" />
				<param name="allowfullscreen" value="true" />
				<param name="allowscriptaccess" value="always" />
							<param name="wmode" value="transparent" />
				<param name="flashvars" value="swfMovie=<?PHP echo $x; ?>" />
				<p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>
			</object>
		</object>
	
	<?PHP
	
}
function printvar($label,$var)
{
	echo "<div class='sm'>Value for ".$label.":".$var."</div>";
}

function chopassets($string)
{
return strstr($string, 'media');
}
function chopurl($string)
{
return strstr($string, 'anino0407');
}

function printinput($name,$id,$label,$size,$max,$value)
{
			echo " 		<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label><input type=text name=".$name." id=textinput class=textinput size=".$size." maxlength=".$max." value='".$value."'   ></div>";

}


function printinputt($name,$id,$label,$size,$max,$value,$tooltip)
{
			echo "<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label>";
					if(!empty($tooltip))
					{
						echo "	<p class='datatip'>".$tooltip."</p>";
					}	
				echo		"<input id=".$id." type=text name=".$name." class=textinput size=".$size." maxlength=".$max." value='".$value."'   >
							
							</div>";

}

function printinput3($name,$label,$size,$max,$value,$tooltip)
{
			echo "<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label>";
					if(!empty($tooltip))
					{
						echo "	<p class='datatip'>".$tooltip."</p>";
					}	
				echo		"<input id=".$name." type=text name=".$name." class=textinput size=".$size." maxlength=".$max." value='".$value."'   >
							
							</div>";

}


function print_input($name,$id,$label,$size,$max,$value,$tooltip,$password,$error)
{
				$class="textinput ".$error;
			
								
				echo "<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label>";
					if(!empty($tooltip))
					{
						echo "	<p class='datatip'>".$tooltip."</p>";
					}	
				
				echo		"<input id=".$name." ";
				if($password){echo " type=password ";}else{echo " type=text ";}
				echo 		" name=".$name." class='".$class."' size=".$size." maxlength=".$max." value='".$value."' >";
							
				echo			"</div>";
							
}

function printdate($name,$id,$label,$size,$max,$value,$tooltip)
{
			echo "<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label>";
					if(!empty($tooltip))
					{
						echo "	<p class='datatip'>".$tooltip."</p>";
					}	
				echo		"<input id=".$id." type=text name=".$name." class=textinput size=".$size." maxlength=".$max." value='".$value."'   >
							
							</div>";
							
							
							?><script type="text/javascript">
							$(function() {
								$("#<?PHP echo $id;?>").datepicker();
								$('#<?PHP echo $id;?>').datepicker('option', {dateFormat: "yy-mm-dd"}); });
							</script>
							
							<?PHP

}



function printtext($name,$id,$label,$size,$max,$value)
{			echo "<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label>";
			echo "<textarea id=textarea class=textarea name=".$name." cols='".$size."' rows='".$max."'>".$value."</textarea></div>";
}


function printtextt($name,$id,$label,$size,$max,$value, $tooltip)
{			echo "<div class='forminfoholder'>
							  <label for=".$name.">".$label."</label>";
							if(!empty($tooltip))
							{
								echo "	<p class='datatip'>".$tooltip."</p>";
							}
			echo "<textarea id=textarea class=textarea name=".$name." cols='".$size."' rows='".$max."'>".$value."</textarea></div>";
}

function printfile($name, $link, $tooltip, $title)
{	
	echo "<div class='forminfoholder'><label for='".$name."'>".$title; 
	
	if(!empty($link))
	{
		echo " - <a href='".$link."'>VIEW original</a>";
	}
	
	echo "</label>"; 
	
	if(!empty($tooltip))
	{
		echo "	<p class='datatip'>".$tooltip."</p>";
	}
	
	echo"<input name='".$name."' class='filebox' type='file'></div> ";
							

}

function print_file($name, $link, $tooltip, $title, $class)
{	
	echo "<div class='forminfoholder'><label for='".$name."'>".$title; 
	
	if(!empty($link))
	{
		echo " - <a href='".$link."'>VIEW original</a>";
	}
	
	echo "</label>"; 
	
	if(!empty($tooltip))
	{
		echo "	<p class='datatip'>".$tooltip."</p>";
	}
	
	echo"<input name='".$name."' class='filebox ".$class."' type='file'></div> ";
							

}




function printsubmit($name)
{			echo " <div class='fi input_holder'><input type=submit value=".$name." class=buttonSubmit /></div>";
			
}


function printdateinput($name,$id,$label,$valMM,$valDD,$valYY,$valHH,$valNN)
{
			echo "<div class='forminfoholder'>
		<label>".$label."</label>
		
		<input type=text name=".$name."MM id=".$name."MM size=4 maxlength=2 value=".$valMM." class=textinput/>MM
		<input type=text name=".$name."DD id=".$name."DD size=4 maxlength=2 value=".$valDD." class=textinput/>DD
		<input type=text name=".$name."YY id=".$name."YY size=8 maxlength=4 value=".$valYY." class=textinput/> YYYY
		<input type=text name=".$name."HH id=".$name."HH size=4 maxlength=2 value=".$valHH." class=textinput/>:
		<input type=text name=".$name."NN id=".$name."NN size=4 maxlength=2 value=".$valNN." class=textinput/>
		</div>";


}

function printdateonlyinput($name,$id,$label,$valMM,$valDD,$valYY)
{
			echo "<div class='forminfoholder'>
		<label>".$label."</label> 
		
		<input type=text name=".$name."MM id=datetextinput size=4 maxlength=2 value=".$valMM." class=datetextinput /> <label class=datetextlabel>Month</label>
		<input type=text name=".$name."DD id=datetextinput size=4 maxlength=2 value=".$valDD." class=datetextinput /> <label class=datetextlabel >Day</label>
		<input type=text name=".$name."YY id=datetextinput size=8 maxlength=4 value=".$valYY." class=datetextinput /> <label class=datetextlabel>Year</label>

		</div>";


}


function printdatatablev2($name,$data, $viewurl, $editurl, $deleteurl, $display,$value, $none)
{
	echo "<table class='mytable minitable' id='".$name."' cellspacing='0'>
	<tbody>";



	
	

foreach ($data as $v1) {
			
			
			
			//	echo "<tr><td>".$v1[$display]."</td></tr>";
			
			
						echo "<tr><td>";
						if(!empty($addurl))
						{
								if(!empty($v1[$value])){
									echo "<a class='viewlinks' href='".$addurl."".$v1[$value]."'>".$v1[$display]."</a>";
								}
						}
						else
						{
							echo $v1[$display];
						}


						echo "</td><td class='tdedit'>";
						if(!empty($editurl))
						{
							if(!empty($v1[$value])){
								echo "<a href='".$editurl."".$v1[$value]."'>Edit</a> <br> ";
							}
						}
						if(!empty($deleteurl))
						{
							if(!empty($v1[$value])){
								echo "<a href='".$deleteurl."".$v1[$value]."'>Delete</a>";
							}

						}



						echo "</td></tr>";
			
	
}
	
	echo "</tbody>
		</table>";
}



function printdatatablev3($name,$data, $viewurl, $editurl, $deleteurl, $display,$value, $key)
{
	echo "<table class='mytable minitable' id='".$name."' cellspacing=0>
	<tbody>";



	
	

foreach ($data as $v1) {
			
			
			
			//	echo "<tr><td>".$v1[$display]."</td></tr>";
			
			
						echo "<tr><td>";
						if(!empty($addurl))
						{
								if(!empty($v1[$value])){
									echo "<a class='viewlinks' href='".$addurl."".$v1[$value]."'>".$v1[$display]."</a>";
								}
						}
						else
						{
							
						//	echo $v1[$key];
							
							
							
							if($v1[$key])
							{
								
								echo "<strong>".$v1[$display]."</strong>";
							}
							
							else
							
							{
								echo $v1[$display];
								
							}
							
							
							
						}


						echo "</td><td class='tdedit'>";
						if(!empty($editurl))
						{
							if(!empty($v1[$value])){
								echo "<a href='".$editurl."".$v1[$value]."'>Edit</a> <br> ";
							}
						}
						if(!empty($deleteurl))
						{
							if(!empty($v1[$value])){
								echo "<a href='".$deleteurl."".$v1[$value]."'>Delete</a>";
							}

						}



						echo "</td></tr>";
			
	
}
	
	echo "</tbody>
		</table>";
}
function print_data_table($headers,$array,$links, $attributes, $show)
{	
	echo "<table ".$attributes." class='sortme'>";
	if(!empty($headers)){
		echo "<thead>";
		foreach ($headers as $x) {
?>
		
			
				<th><?PHP echo $x;?></th>
				
		
<?PHP	 
		}
		echo "</thead>";
	}
	foreach ($array as $x)
	{?>
	
		<tr>
			<?PHP
			$r=0;
		
			
			foreach($x as $y)
			{
				
				foreach($show as $z)
				{
					
					
					if($r==$z)
					{
						
								?>

								<td><?PHP echo $y;?></td>	

								<?PHP
						
						
					}
				}
				
				
			$r++;
			}
			?>
		
			<td>
				<?PHP
				
					foreach($links as $links_key => $value)
					{
							if(isset($x[0])){echo "<a href='".$links[$links_key].$x[0]."'>".$links_key."</a>";};
					//	echo $links[$links_key];
					}
				
				?>
			</td>
		</tr>
	
	<?PHP }
	echo "</table>";
	?>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() 
		    { 
		        $(".sortme").tablesorter( ); 
		    } 
		);
	</script>
	
	<?PHP
}








function print_data_table_2($headers,$array,$links, $attributes, $show,$ajax_array)
{	
	echo "<table ".$attributes." class='sortme' cellspacing='0'>";
	if(!empty($headers)){
		echo "<thead>";
		foreach ($headers as $x) {
?>
		
			
				<th><?PHP echo $x;?></th>
				
		
<?PHP	 
		}
		echo "</thead>";
	}
	foreach ($array as $x)
	{?>
	
		<tr>
			<?PHP
			//$r=0;
			foreach($show as $z)
			{
				echo "<td>".$x[$z]."</td>";
			}
			
		
			?>
		
			<td>
				<?PHP
				
					foreach($links as $links_key => $value)
					{
							if(isset($x[0])){echo "<a href='".$links[$links_key].$x[0]."'>".$links_key."</a>";};
					//	echo $links[$links_key];
					}
				
				?>
				<?PHP
				
					foreach($ajax_array as $ajax_key => $value)
					{ 
						echo '<a href="#" id="'.$x[0].'" class="'.$ajax_key.'">'.$ajax_key.'</a>';
					}
					
				?>
				
			</td>
		</tr>
	
	<?PHP }
	echo "</table>";
	?>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() 
		    { 
		        $(".sortme").tablesorter( ); 
		    } 
		);
		
		<?PHP
		
			foreach($ajax_array as $ajax_key => $value)
			{ 
		?>
		
			$(function() {
			$(".<?PHP echo $ajax_key;?>").click(function() {

			var commentContainer = $(this).parent().parent();

			var id = $(this).attr("id");
			var string = 'id='+ id ;

				var answer = confirm("<?PHP echo $ajax_key;?> this item?")
			            if (answer){
			                $.ajax({
							   type: "POST",
							   url: "<?PHP echo $ajax_array[$ajax_key];?>",
							   data: string,
							   cache: false,
								<?PHP if($ajax_key=='Delete'){?>
							   			success: function(){
										commentContainer.fadeOut('slow', function() {$(this).remove();});
										}
								<?PHP };?>
							  

							 });
			            }
			            else{
			                return false;
			            };
						return false;
				});
			});
		
		
				
		<?PHP

			}
			
		?>

	
		
		
		
	</script>
	
	<?PHP
}



function printdatatable($name, $data, $viewurl, $editurl, $deleteurl)
{
	echo "<table class='mytable' id='".$name."' cellspacing=0>
	<tbody>";
	
	
	
	
	
	foreach ($data as $v1) {
		 $m=0;
	    foreach ($v1 as $v2) {
		
		
		
	        if($m==0)
			{
				

			$v2val=$v2;
				$m=1;
				
			
				 
			}
		
			else
			{
				
				echo "<tr><td>";
				if(!empty($addurl))
				{
					echo "<a class='viewlinks' href='".$addurl."".$v2val."'>".$v2."</a>";
				}
				else
				{
					echo $v2;
				}
					
				
				echo "</td><td class='tdedit'>";
				if(!empty($editurl))
				{
					echo "<a href='".$editurl."".$v2val."'>Edit</a> <br> ";
				}
				if(!empty($deleteurl))
				{
						echo "<a href='".$deleteurl."".$v2val."'>Delete</a>";
					
				}
					
				
				
				echo "</td>";

			}

	    }
	}
	
	
	
	
	
	echo "</tbody>
		</table>";
}
function printselect($name,$data,$selectedvalue, $tooltip, $title)
{
	echo "
	
		<div class='forminfoholder'>
<label for=".$name.">".$title."</label>";
	if(!empty($tooltip))
	{
		echo "	<p class='datatip'>".$tooltip."</p>";
	}


	
	
echo "

<select name=".$name." id=".$name." class=formselect >";

foreach ($data as $v1) {
	 $m=0;
    foreach ($v1 as $v2) {
        if($m==0)
		{
			echo "<option ";
			
			if($v2==$selectedvalue)
			{ echo " selected='selected' ";}
			echo "value=".$v2;
			$m=1; 
		}
		else
		{
			echo ">".$v2."</option>";
			
		}
		
    }
}
echo "
</select>
</div>
	
	
	";
}
function printradio($name,$title,$data,$tooltip,$checked)
{
	
		echo "	<div class='forminfoholder'>
	<label for=".$name.">".$title."</label>";
	
	if(!empty($tooltip))
	{
		echo "	<p class='datatip'>".$tooltip."</p>";
	}
	echo '<ul class="radioarea">';
	foreach ($data as $y)
	{
		echo '<li><input type="radio" name="'.$name.'" value="'.$y[0].'" ';
			if($y[0]==$checked)
			{
				echo 'checked="checked"';
			}
		echo '/> '.$y[1].'</li>';
		
	}
	
	echo "</ul></div>	";
}




function printselectv2($name,$data,$selectedvalue, $tooltip, $title, $display,$value, $none)
{
	echo "	<div class='forminfoholder'>
<label for=".$name.">".$title."</label>";
	if(!empty($tooltip))
	{
		echo "	<p class='datatip'>".$tooltip."</p>";
	}


	
	
echo "

<select name=".$name." id=".$name." class=formselect >";
if($none)
{
	echo "<option value='0'>None</option>";
}
foreach ($data as $v1) {

			echo "<option ";
			
			if($v1[$value]==$selectedvalue)
			{ echo " selected='selected' ";}
			echo "value=".$v1[$value];
			$m=1; 
	
			echo ">".$v1[$display]."</option>";
			
	
}
echo "
</select>
</div>
	
	
	";
}

function printselectclean($name,$data,$selectedvalue, $tooltip, $title)
{

	
echo "<select name=".$name." id=".$name." class=formselect >";

foreach ($data as $v1) {
	 $m=0;
	
	foreach ($v1 as $v2) {
	       if($m==0)
			{
				echo "<option ";

				if($v2==$selectedvalue)
				{ echo " selected='selected' ";}
				echo "value=".$v2;
				$m=1; 
			}
			else
			{
				echo ">".$v2."</option>";

			}

	   }
   
}
echo "</select>	";
}


function paginatemenu($page, $count, $items, $file)
{
	
	$number_of_pages = ceil($count / $items);
	print "<a href=\"".$file."page=1\">First Page</a> ";
	
	for($i = 2; $i < $number_of_pages; $i++) {
		print "<a href=\"".$file."page=".$i."\">".$i."</a> ";
	}
	
	print "<a href=\"".$file."page=".$number_of_pages."\">Last Page</a> ";
	
}

function paginatenext($page, $count, $items, $file)
{
	
	$number_of_pages = ceil($count / $items);
	
	$i=$page-1;
	if($page != 1)
	{
		print "<a href=\"".$file."page=".$i."\" id='older_post'>Older Post</a> ";
	}
	for($i = 2; $i < $number_of_pages; $i++) {
	//	print "<a href=\"".$file."page=".$i."\">".$i."</a> ";
	}
	$z=$page+1;
	$v=$count+1;
	
	if($v != $z)
	{
			print "<a href=\"".$file."page=".$z."\" id='newer_post'>Newer Post</a> ";
	}

	
}
function get_ph_regions()
{
	$ph_regions = array(
		'NCR'=>'NCR (Metro Manila)',
		'Region1'=>'1 - Ilocos ',
		'Region2'=>'2 - Cagayan Valley',
		'Region3'=>'3 - Central Luzon',
		'Region4'=>'4 - CALABARZON / MIMAROPA',
		'Region5'=>'5 - Bicol Region',
		'Region6'=>'6 - Western Visayas',
		'Region7'=>'7 - Central Visayas',
		'Region8'=>'8 - Eastern Visayas',
		'Region9'=>'9 - Zamboanga Peninsula',
		'Region10'=>'10 - Northern Mindanao',
		'Region11'=>'11 - Davao Region',
		'Region12'=>'12 - SOCCSKSARGEN',
		'CAR'=>'CAR',
		'ARMM'=>'ARMM',
		'Caraga'=>'Caraga'
		
		);
		
			foreach ($ph_regions as $post_key => $value)
			{
				$x[0]=$post_key;
				$x[1]=$value;
				$m[]=$x;
			}
			return $m;
}
function get_countries()
{

		$ar_countries = array(
			'PH'=>'PHILIPPINES',
			'AF'=>'AFGHANISTAN',
			'AL'=>'ALBANIA',
			'DZ'=>'ALGERIA',
			'AS'=>'AMERICAN SAMOA',
			'AD'=>'ANDORRA',
			'AO'=>'ANGOLA',
			'AI'=>'ANGUILLA',
			'AQ'=>'ANTARCTICA',
			'AG'=>'ANTIGUA AND BARBUDA',
			'AR'=>'ARGENTINA',
			'AM'=>'ARMENIA',
			'AW'=>'ARUBA',
			'AU'=>'AUSTRALIA',
			'AT'=>'AUSTRIA',
			'AZ'=>'AZERBAIJAN',
			'BS'=>'BAHAMAS',
			'BH'=>'BAHRAIN',
			'BD'=>'BANGLADESH',
			'BB'=>'BARBADOS',
			'BY'=>'BELARUS',
			'BE'=>'BELGIUM',
			'BZ'=>'BELIZE',
			'BJ'=>'BENIN',
			'BM'=>'BERMUDA',
			'BT'=>'BHUTAN',
			'BO'=>'BOLIVIA',
			'BA'=>'BOSNIA AND HERZEGOVINA',
			'BW'=>'BOTSWANA',
			'BV'=>'BOUVET ISLAND',
			'BR'=>'BRAZIL',
			'IO'=>'BRITISH INDIAN OCEAN TERRITORY',
			'BN'=>'BRUNEI DARUSSALAM',
			'BG'=>'BULGARIA',
			'BF'=>'BURKINA FASO',
			'BI'=>'BURUNDI',
			'KH'=>'CAMBODIA',
			'CM'=>'CAMEROON',
			'CA'=>'CANADA',
			'CV'=>'CAPE VERDE',
			'KY'=>'CAYMAN ISLANDS',
			'CF'=>'CENTRAL AFRICAN REPUBLIC',
			'TD'=>'CHAD',
			'CL'=>'CHILE',
			'CN'=>'CHINA',
			'CX'=>'CHRISTMAS ISLAND',
			'CC'=>'COCOS (KEELING) ISLANDS',
			'CO'=>'COLOMBIA',
			'KM'=>'COMOROS',
			'CG'=>'CONGO',
			'CD'=>'CONGO, THE DEMOCRATIC REPUBLIC OF THE',
			'CK'=>'COOK ISLANDS',
			'CR'=>'COSTA RICA',
			'CI'=>'COTE D IVOIRE',
			'HR'=>'CROATIA',
			'CU'=>'CUBA',
			'CY'=>'CYPRUS',
			'CZ'=>'CZECH REPUBLIC',
			'DK'=>'DENMARK',
			'DJ'=>'DJIBOUTI',
			'DM'=>'DOMINICA',
			'DO'=>'DOMINICAN REPUBLIC',
			'TP'=>'EAST TIMOR',
			'EC'=>'ECUADOR',
			'EG'=>'EGYPT',
			'SV'=>'EL SALVADOR',
			'GQ'=>'EQUATORIAL GUINEA',
			'ER'=>'ERITREA',
			'EE'=>'ESTONIA',
			'ET'=>'ETHIOPIA',
			'FK'=>'FALKLAND ISLANDS (MALVINAS)',
			'FO'=>'FAROE ISLANDS',
			'FJ'=>'FIJI',
			'FI'=>'FINLAND',
			'FR'=>'FRANCE',
			'GF'=>'FRENCH GUIANA',
			'PF'=>'FRENCH POLYNESIA',
			'TF'=>'FRENCH SOUTHERN TERRITORIES',
			'GA'=>'GABON',
			'GM'=>'GAMBIA',
			'GE'=>'GEORGIA',
			'DE'=>'GERMANY',
			'GH'=>'GHANA',
			'GI'=>'GIBRALTAR',
			'GR'=>'GREECE',
			'GL'=>'GREENLAND',
			'GD'=>'GRENADA',
			'GP'=>'GUADELOUPE',
			'GU'=>'GUAM',
			'GT'=>'GUATEMALA',
			'GN'=>'GUINEA',
			'GW'=>'GUINEA-BISSAU',
			'GY'=>'GUYANA',
			'HT'=>'HAITI',
		//	'HM'=>'HEARD ISLAND AND MCDONALD ISLANDS',
			'VA'=>'HOLY SEE (VATICAN)',
			'HN'=>'HONDURAS',
			'HK'=>'HONG KONG',
			'HU'=>'HUNGARY',
			'IS'=>'ICELAND',
			'IN'=>'INDIA',
			'ID'=>'INDONESIA',
			'IR'=>'IRAN, ISLAMIC REPUBLIC OF',
			'IQ'=>'IRAQ',
			'IE'=>'IRELAND',
			'IL'=>'ISRAEL',
			'IT'=>'ITALY',
			'JM'=>'JAMAICA',
			'JP'=>'JAPAN',
			'JO'=>'JORDAN',
			'KZ'=>'KAZAKSTAN',
			'KE'=>'KENYA',
			'KI'=>'KIRIBATI',
		//	'KP'=>'KOREA DEMOCRATIC PEOPLES REPUBLIC OF',
			'KR'=>'KOREA REPUBLIC OF',
			'KW'=>'KUWAIT',
			'KG'=>'KYRGYZSTAN',
			'LA'=>'LAO PEOPLES DEMOCRATIC REPUBLIC',
			'LV'=>'LATVIA',
			'LB'=>'LEBANON',
			'LS'=>'LESOTHO',
			'LR'=>'LIBERIA',
			'LY'=>'LIBYAN ARAB JAMAHIRIYA',
			'LI'=>'LIECHTENSTEIN',
			'LT'=>'LITHUANIA',
			'LU'=>'LUXEMBOURG',
			'MO'=>'MACAU',
			'MK'=>'MACEDONIA',
			'MG'=>'MADAGASCAR',
			'MW'=>'MALAWI',
			'MY'=>'MALAYSIA',
			'MV'=>'MALDIVES',
			'ML'=>'MALI',
			'MT'=>'MALTA',
			'MH'=>'MARSHALL ISLANDS',
			'MQ'=>'MARTINIQUE',
			'MR'=>'MAURITANIA',
			'MU'=>'MAURITIUS',
			'YT'=>'MAYOTTE',
			'MX'=>'MEXICO',
			'FM'=>'MICRONESIA, FEDERATED STATES OF',
			'MD'=>'MOLDOVA, REPUBLIC OF',
			'MC'=>'MONACO',
			'MN'=>'MONGOLIA',
			'MS'=>'MONTSERRAT',
			'MA'=>'MOROCCO',
			'MZ'=>'MOZAMBIQUE',
			'MM'=>'MYANMAR',
			'NA'=>'NAMIBIA',
			'NR'=>'NAURU',
			'NP'=>'NEPAL',
			'NL'=>'NETHERLANDS',
			'AN'=>'NETHERLANDS ANTILLES',
			'NC'=>'NEW CALEDONIA',
			'NZ'=>'NEW ZEALAND',
			'NI'=>'NICARAGUA',
			'NE'=>'NIGER',
			'NG'=>'NIGERIA',
			'NU'=>'NIUE',
			'NF'=>'NORFOLK ISLAND',
			'MP'=>'NORTHERN MARIANA ISLANDS',
			'NO'=>'NORWAY',
			'OM'=>'OMAN',
			'PK'=>'PAKISTAN',
			'PW'=>'PALAU',
			'PS'=>'PALESTINIAN TERRITORY, OCCUPIED',
			'PA'=>'PANAMA',
			'PG'=>'PAPUA NEW GUINEA',
			'PY'=>'PARAGUAY',
			'PE'=>'PERU',
			
			'PN'=>'PITCAIRN',
			'PL'=>'POLAND',
			'PT'=>'PORTUGAL',
			'PR'=>'PUERTO RICO',
			'QA'=>'QATAR',
			'RE'=>'REUNION',
			'RO'=>'ROMANIA',
			'RU'=>'RUSSIAN FEDERATION',
			'RW'=>'RWANDA',
			'SH'=>'SAINT HELENA',
			'KN'=>'SAINT KITTS AND NEVIS',
			'LC'=>'SAINT LUCIA',
			'PM'=>'SAINT PIERRE AND MIQUELON',
			'VC'=>'SAINT VINCENT AND THE GRENADINES',
			'WS'=>'SAMOA',
			'SM'=>'SAN MARINO',
			'ST'=>'SAO TOME AND PRINCIPE',
			'SA'=>'SAUDI ARABIA',
			'SN'=>'SENEGAL',
			'SC'=>'SEYCHELLES',
			'SL'=>'SIERRA LEONE',
			'SG'=>'SINGAPORE',
			'SK'=>'SLOVAKIA',
			'SI'=>'SLOVENIA',
			'SB'=>'SOLOMON ISLANDS',
			'SO'=>'SOMALIA',
			'ZA'=>'SOUTH AFRICA',
		//	'GS'=>'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
			'ES'=>'SPAIN',
			'LK'=>'SRI LANKA',
			'SD'=>'SUDAN',
			'SR'=>'SURINAME',
			'SJ'=>'SVALBARD AND JAN MAYEN',
			'SZ'=>'SWAZILAND',
			'SE'=>'SWEDEN',
			'CH'=>'SWITZERLAND',
			'SY'=>'SYRIAN ARAB REPUBLIC',
			'TW'=>'TAIWAN, PROVINCE OF CHINA',
			'TJ'=>'TAJIKISTAN',
			'TZ'=>'TANZANIA, UNITED REPUBLIC OF',
			'TH'=>'THAILAND',
			'TG'=>'TOGO',
			'TK'=>'TOKELAU',
			'TO'=>'TONGA',
			'TT'=>'TRINIDAD AND TOBAGO',
			'TN'=>'TUNISIA',
			'TR'=>'TURKEY',
			'TM'=>'TURKMENISTAN',
			'TC'=>'TURKS AND CAICOS ISLANDS',
			'TV'=>'TUVALU',
			'UG'=>'UGANDA',
			'UA'=>'UKRAINE',
			'AE'=>'UNITED ARAB EMIRATES',
			'GB'=>'UNITED KINGDOM',
			'US'=>'UNITED STATES',
		//	'UM'=>'UNITED STATES MINOR OUTLYING ISLANDS',
			'UY'=>'URUGUAY',
			'UZ'=>'UZBEKISTAN',
			'VU'=>'VANUATU',
			'VE'=>'VENEZUELA',
			'VN'=>'VIET NAM',
			'VG'=>'VIRGIN ISLANDS, BRITISH',
			'VI'=>'VIRGIN ISLANDS, U.S.',
			'WF'=>'WALLIS AND FUTUNA',
			'EH'=>'WESTERN SAHARA',
			'YE'=>'YEMEN',
			'YU'=>'YUGOSLAVIA',
			'ZM'=>'ZAMBIA',
			'ZW'=>'ZIMBABWE'
		);
		foreach ($ar_countries as $post_key => $value)
		{
			$x[0]=$post_key;
			$x[1]=$value;
			$m[]=$x;
		}
		return $m;

}


 function cURLcheckBasicFunctions() 
{ 
  if( !function_exists("curl_init") && 
      !function_exists("curl_setopt") && 
      !function_exists("curl_exec") && 
      !function_exists("curl_close") ) return false; 
  else return true; 
} 

function cURLdownload($url, $file) 
{ 
  if( !cURLcheckBasicFunctions() ) return "UNAVAILABLE: cURL Basic Functions"; 
  $ch = curl_init(); 
  if($ch) 
  { 
    $fp = fopen($file, "w"); 
    if($fp) 
    { 
      if( !curl_setopt($ch, CURLOPT_URL, $url) ) 
      { 
        fclose($fp); // to match fopen() 
        curl_close($ch); // to match curl_init() 
        return "FAIL: curl_setopt(CURLOPT_URL)"; 
      } 
      if( !curl_setopt($ch, CURLOPT_FILE, $fp) ) return "FAIL: curl_setopt(CURLOPT_FILE)"; 
      if( !curl_setopt($ch, CURLOPT_HEADER, 0) ) return "FAIL: curl_setopt(CURLOPT_HEADER)"; 
      if( !curl_exec($ch) ) return "FAIL: curl_exec()"; 
      curl_close($ch); 
      fclose($fp); 
      return "SUCCESS: $file [$url]"; 
    } 
    else return "FAIL: fopen()"; 
  } 
  else return "FAIL: curl_init()"; 
}



	
?>